package com.qbccn.usercenter.controller;

import com.qbccn.usercenter.dto.ResponsePageResult;
import com.qbccn.usercenter.dto.ResponseResult;
import com.qbccn.usercenter.service.SystemService;
import com.qbccn.usercenter.service.UserService;
import com.qbccn.usercenter.vo.TreeListVo;
import com.qbccn.usercenter.vo.UserFindListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author linke
 * @date 2020/5/24 22:45
 * @description
 */
@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private HttpServletRequest request;

    @Autowired
    private SystemService systemService;
    @Autowired
    private UserService userService;

    @GetMapping("userFindList")
    @ResponseBody
    public ResponsePageResult<List<UserFindListVo>> userFindList(Integer page, Integer size, String username) {
        if (page == null) {
            page = 1;
        }
        if (size == null) {
            size = 10;
        }
        if (StringUtils.isEmpty(username))
            username = null;
        return userService.getUserFindListVo(null, username, page, size);
    }

    @GetMapping("orderListFind")
    @ResponseBody
    public ResponseResult<List<TreeListVo>> orderListFind(String systemCode) {
        if (StringUtils.isEmpty(systemCode))
            return null;
        return userService.getTreeListBySystemCode(systemCode);
    }

}
